# -*- coding: UTF-8 -*-

import MySQLdb
from testdemo.com.bean.User import User

class SysInfoDao:
    def __init__(self,sql):
        self.sql = sql;

    def query(self):
        list = [];
        # 打开数据库连接
        db = MySQLdb.connect("192.168.0.62", "root", "root", "sys_info")

        # 使用cursor()方法获取操作游标
        cursor = db.cursor()

        # SQL 查询语句
        #sql = "SELECT * FROM EMPLOYEE \
         #      WHERE INCOME > '%d'" % (1000)
        try:
            # 执行SQL语句
            cursor.execute(self.sql)
            # 获取所有记录列表
            results = cursor.fetchall()
            for row in results:
                percent = row[0]
                list.append(percent)
        except:
            print "Error: unable to fecth data"

        # 关闭数据库连接
        db.close()
        return list